package org.example.enums;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 枚举实现
 * @author:  yh
 * @date:  2022/12/11
 */
public enum Singleton {
    uniqueInstance;
    private static String name;

    private void Singleton(){
    }
    public void doSomething() {
        System.out.println(name);
    }


    /**
     * 使用内部类注入
     * @author:  yh
     * @date:  2022/12/11
     */
    @Component
    static class PeopleEnumContainer {
        @Value("${people.name}")
        public void init(String name) {
            Singleton.name = name;
        }
    }
}